package org.example.util;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.example.util.constantUtil.ConstantUtil;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.*;

@Component
@Data
@Slf4j
public class DeviceUtil {
    //imei码与设备ID映射表，原来是SN的所以叫这个名字
    public static Map<String ,String> SNtoUUID= new HashMap<>();
    // imei码与创建时间映射
    public static Map<String, Long> ImeiCreatedTime= new HashMap<>();
    // imei码与客户的映射
    public static Map<String, String> ImeiCustomerTitle= new HashMap<>();
    // uuid与customerTitle的映射
    public static Map<String, String> uuidCustomerTitle=new HashMap<>();
    // 客户列表
    public static List<String> customerTitleList = new LinkedList<>();
    // customerTitle-设备列表映射
    public static Map<String,List<String>> customerTitleDeviceList=new HashMap<>();


    // uuid获取imei
    public static String getKey(String value) {
        String key = null;
        //Map,HashMap并没有实现Iteratable接口,不能用增强for循环
        for (String getkey : SNtoUUID.keySet()) {
            if (SNtoUUID.get(getkey).equals(value)) {
                key = getkey;
            }
        }
        return key;
    }

    /**
     * 获取设备创建时间
     * @param imei 设备imei号
     * @return 设备创建的时间戳
     */
    public static Long getDeviceCreatedTime(String imei){
        return ImeiCreatedTime.get(imei);
    }




}
